var t = getApp(), e = t.requirejs('core');
Page({
    data: {
        list: [],
        isend: false,
        page: 1,
        cate: 1
    },
    onLoad() {
        this.get_list();
    },
    cate(s) {
        let id = s.currentTarget.dataset.type;
        this.setData({
            cate: id,
            isend: false,
            page: 1
        })
        this.get_list();
    },
    get_list() {
        let _this = this;
        if(!_this.data.isend) e.get("syt.merch.get_yue_list", {page: _this.data.page, status: _this.data.cate}, res => {
            console.log(res.list);
            // 判断类型
            if (typeof(res.list) !== 'object' && !res.list.length) {
                res.list = []
            }
            let list = _this.data.page != 1 ? _this.data.list : [], data = res.list;
            data.length && data.forEach(item => {
                list.push(item)
            })
            if(data.length < res.pagesize) _this.setData({
                isend: true
            })
            _this.setData({
                list: list
            })
        })
    },
    onReachBottom() {
        if(!this.data.isend) {
            this.setData({
                page: this.data.page + 1
            })
            this.get_list();
        }
    }
})